﻿using FangPage.Common;
using FangPage.Core;
using FangPage.User.Model;
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text;

namespace FangPage.User
{
    public class FPUser
    {
        /// <summary>
        /// 登录认证信息
        /// </summary>
        /// <returns></returns>
        public static AuthInfo Authorize()
        {
            AuthInfo authinfo = new AuthInfo();

            if (FPContext.HttpContext.User.Identity.IsAuthenticated)
            {
                authinfo.islogin = true;
                authinfo.username = FPContext.HttpContext.User.Identity.Name;
                authinfo.userid = FPContext.HttpContext.User.FindFirstValue("userid");
                authinfo.token = FPContext.HttpContext.User.FindFirstValue("token");
                authinfo.realname = FPContext.HttpContext.User.FindFirstValue("realname");
                authinfo.roleid = FPContext.HttpContext.User.FindFirstValue("roleid");
                authinfo.rolename = FPContext.HttpContext.User.FindFirstValue("rolename");
                authinfo.departid = FPContext.HttpContext.User.FindFirstValue("departid");
                authinfo.departname = FPContext.HttpContext.User.FindFirstValue("departname");
                authinfo.departs = FPContext.HttpContext.User.FindFirstValue("departs");
                authinfo.isadmin = FPUtils.ToShort(FPContext.HttpContext.User.FindFirstValue("isadmin"));
            }

            return authinfo;
        }


    }
}
